<!-- ISCSI -->
<template>
  <div>
    <a-tabs
      :default-active-key="defaultActiveKey"
      @change="changeTab"
    >
      <!-- 访问路径 -->
      <a-tab-pane key="ACCESS_PATH" :tab="$t('Access-path')">
        <NoAuthPage v-showNoAuth="'D7-1'" :imgBoxStyle="{height:'65vh',margin:0}"/>

        <AccessPath
          v-if="isHasAccessPath && currentTabKey=='ACCESS_PATH'"
        />
      </a-tab-pane>
      <!-- 客户端组 -->
      <a-tab-pane key="USER_GROUP" :tab="$t('Client-group')">
        <NoAuthPage v-showNoAuth="'D22'" :imgBoxStyle="{height:'65vh',margin:0}"/>

        <ClientGroup
          v-if="isHasClient && currentTabKey=='USER_GROUP'"
        />
      </a-tab-pane>
      <!-- 客户端 -->
      <!-- <a-tab-pane key="CLIENT" :tab="$t('Client')">
        <Client 
          v-if="currentTabKey=='CLIENT'"
        />
      </a-tab-pane> -->
    </a-tabs>
  </div>
</template>

<script>
// import Client from '@/components/storage_mgr/block/iscsi'
import AccessPath from '@/views/storage_mgr/osd/iscsi/AccessPath'
import ClientGroup from '@/views/storage_mgr/osd/iscsi/ClientGroup'
import NoAuthPage from '@/components/common/NoAuthPage'

export default {
  name: "ISCSI",
  components: { ClientGroup, AccessPath, NoAuthPage },
  data() {
    return {
      defaultActiveKey: 'ACCESS_PATH',
      currentTabKey: 'ACCESS_PATH',
      isHasAccessPath: true,
      isHasClient: true,
    }
  },

  created() {
    this.currentTabKey = JSON.parse(localStorage.getItem('iscsi_tab')) || 'ACCESS_PATH';
    this.defaultActiveKey = JSON.parse(localStorage.getItem('iscsi_tab')) || 'ACCESS_PATH';
    const tags = localStorage.getItem('tags');
    if(tags.indexOf('D7-1') === -1) {
      this.isHasAccessPath = false;
    }
    if(tags.indexOf('D22') === -1) {
      this.isHasClient = false;
    }
  },

  beforeDestroy() {
    localStorage.removeItem('iscsi_tab');
  },

  methods: {
    // 切换tab
    changeTab(key) {
      this.currentTabKey = key;
      localStorage.setItem('iscsi_tab', JSON.stringify(key));
    }
  },
}
</script>
<style scoped>
  ::v-deep.ant-tabs-nav-container {
    background-color: #f0f3f5;
    /* padding-left: 10px; */
  }
   ::v-deep.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab {
    border: none;
    background-color: transparent;
  }
  ::v-deep.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active {
    background-color: #fff;
    border-bottom: 2px solid var(--themeColor);
  } 
  
  /* 添加选中tab的下划线 */
  ::v-deep.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active::after {
    position: absolute;
    bottom: 0;
    left: 50%;
    content: '';
    width: 45px;
    height: 2px;
    transform: translateX(-50%);
    background-color: var(--themeColor);
  }
</style>